# 导入upyun
import upyun
# 封装成类的形式
class MyUp:
    def __init__(self):
        #                        服务名     用户名username      密码password
        self.up = upyun.UpYun('lvhualong','lvhualong123','8W1ey1da5Qh37vji4jNhYA5WbN2LocXB')
        # self.address = '../static/upload/'



    # 上传文件
    def upload(self,upload_dir,file,userid):
        # print(self.address+'/'+str(userid)+'/'+file)
        #          打开这个文件
        with open(upload_dir,'rb') as f:
            #       上传                     路径
            self.up.put('/'+str(userid)+'/'+file,f)
        return 'ok'


myup = MyUp()
#                           复制路径                                                                  文件名                      userid
myup.upload('E:/p6/p6/p6/p6_education/static/upload/1/111.jpg','111.jpg',2)
